# coding: utf-8
# Author: zhenda


from sqlalchemy import *
from sqlalchemy.ext.automap import automap_base


class Config:
    # windows的mysql
    # 配置数据库和sqlalchemy
    # HOSTNAME = '127.0.0.1'
    HOSTNAME = '192.168.110.1'
    PORT = '3306'
    DATABASE = 'test2'
    USERNAME = 'root'
    PASSWORD = 'root'
    DB_URI = 'mysql+pymysql://%s:%s@%s:%s/%s?charset=utf8mb4' % \
             (USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE)

    SQLALCHEMY_DATABASE_URI = DB_URI
    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 不需要跟踪数据库中数据的修改

    # 日志的配置
    LOGGING_LEVEL = 'DEBUG'
    LOGGING_FILE_DIR = './logs'
    LOGGING_FILE_MAX_BYTES = 300 * 1024 * 1024  # 300 MB
    LOGGING_FILE_BACKUP = 10

    # centos的redis
    # redis保存数据， 安装flask-redis
    RATELIMIT_STORAGE_URL = 'redis://192.168.110.3:6379/0'
    RATELIMIT_STRATEGY = 'moving-window'  # 时间窗口自动变化

    # redis 数据库连接地址, 使用数据库1来存放缓存数据， 包括短信验证码
    REDIS_URL = 'redis://192.168.110.3:6379/1'


# 开发环境下的配置信息
class DevelopmentConfig(Config):
    DEBUG = True
    SQLALCHEMY_ECHO = True  # 打印sql语句


class ProductConfig(Config):
    pass
